package com.haircut.project.controller.finance;

import com.haircut.project.service.finance.IFinanceDeptService;
import com.haircut.project.vo.finance.*;
import com.modular.result.PageResult;
import com.modular.result.RspMessage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/b/finance")
public class FinanceController {
    @Autowired
    private IFinanceDeptService financeDeptService;
    /**
     * 查询下游部门
     * @return
     */
    @ApiOperation(value = "查询下游部门")
    @PostMapping("findSunDeptPage")
    public RspMessage<PageResult<FinanceResVo>> findSunDeptPage(@RequestBody FinanceReqVo reqVo){
        return RspMessage.success(financeDeptService.findSunDeptPage(reqVo));
    }

    /**
     * 查询下游部门
     * @return
     */
    @ApiOperation(value = "和上游部门对账")
    @PostMapping("findParentDeptPage")
    public RspMessage<PageResult<FinanceResVo>> findParentDeptPage(@RequestBody FinanceReqVo reqVo){
        return RspMessage.success(financeDeptService.findParentDeptPage(reqVo));
    }

    /**
     * 查询下游部门
     * @return
     */
    @ApiOperation(value = "查询统计详情")
    @PostMapping("findDeptStaticPage")
    public RspMessage<List<FinanceStatsResVo>> findDeptStaticPage(@RequestBody FinanceStatsReqVo reqVo){
        return RspMessage.success(financeDeptService.findDeptStaticPage(reqVo));
    }

    /**
     * 提交财务信息
     * @return
     */
    @ApiOperation(value = "提交财务信息")
    @PostMapping("submitFinance")
    public RspMessage<Void> submitFinance(@Validated @RequestBody SubmitFinanceVo reqVo){
        financeDeptService.submitFinance(reqVo);
        return RspMessage.success();
    }
    /**
     * 提交财务信息
     * @return
     */
    @ApiOperation(value = "保存财务信息")
    @PostMapping("editFinance")
    public RspMessage<Void> editFinance(@Validated @RequestBody SubmitFinanceVo reqVo){
        financeDeptService.editFinance(reqVo);
        return RspMessage.success();
    }

    /**
     * 提交财务信息
     * @return
     */
    @ApiOperation(value = "核查数据")
    @GetMapping("checkFinance")
    public RspMessage<Void> checkFinance(@ApiParam("财务id") @RequestParam("id") String id){
        financeDeptService.checkFinance(id);
        return RspMessage.success();
    }
}
